package com.quanyan.platform.service.impl;

import com.quanyan.common.constants.Constants;
import com.quanyan.platform.model.db.TbCirclePlaceRelation;
import com.quanyan.platform.model.db.TbCirclePlaceRelationExample;
import com.quanyan.platform.mapper.TbCirclePlaceRelationMapper;
import com.quanyan.platform.service.ICirclePlaceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by jingliu on 17/3/13.
 */
@Service("circlePlaceService")
public class CirclePlaceServiceImpl implements ICirclePlaceService{
	@Autowired
	private TbCirclePlaceRelationMapper tbCirclePlaceRelationMapper;


	private static final Logger logger = LoggerFactory.getLogger(CirclePlaceServiceImpl.class);

	@Override
	public List<TbCirclePlaceRelation> findTbCirclePlaceRelations(TbCirclePlaceRelation tbCirclePlaceRelation) {
		TbCirclePlaceRelationExample example = new TbCirclePlaceRelationExample();
		TbCirclePlaceRelationExample.Criteria criteria = example.createCriteria();
		if (null != tbCirclePlaceRelation.getCircleId()){
			criteria.andCircleIdEqualTo(tbCirclePlaceRelation.getCircleId());
		}
		if (null != tbCirclePlaceRelation.getCategoryId()){
			criteria.andCategoryIdEqualTo(tbCirclePlaceRelation.getCategoryId());
		}
		if (null != tbCirclePlaceRelation.getIsReport()){
			criteria.andIsReportEqualTo(tbCirclePlaceRelation.getIsReport());
		}
		if (null != tbCirclePlaceRelation.getPlaceId()){
			criteria.andPlaceIdEqualTo(tbCirclePlaceRelation.getPlaceId());
		}
		criteria.andIsDeleteEqualTo(Constants.IS_DELETE_FALSE);
		example.setOrderByClause(" update_time desc");
		return tbCirclePlaceRelationMapper.selectByExample(example);
	}
}
